package com.vipsoft.base.util;


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil {

    /**
     * 获取字段值
     *
     * @param url
     * @param field
     * @return
     */
    public static String getUrlParamValue(String url, String field) {
        String result = "";
        Pattern pXM = Pattern.compile(field + "=([^&]*)");
        Matcher mXM = pXM.matcher(url);
        while (mXM.find()) {
            result = mXM.group(1);
        }
        return result;
    }

    /**
     * 检查密码规则（8-16 位，只能包含数字和字母，不能包含特殊符号）
     * @param password
     * @return
     */
    public static boolean passwordCheck(String password){
        String regex = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$";
        return password.matches(regex);
    }

}
